package org.example.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2023/12/4 09:44
 * @apiNote  中序遍历    左中右
 */

public class Test00094InorderTraversal {


    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        inorder(root,res);
        return res;
    }

    public void inorder(TreeNode root, List<Integer> res){
        if(root == null){
            return;
        }
        inorder(root.left, res);
        res.add(root.val);
        inorder(root.right, res);
    }

}
